package com.shujia.flink.tf

import org.apache.flink.api.common.functions.FilterFunction
import org.apache.flink.streaming.api.scala._

object Demo3Filter {
  def main(args: Array[String]): Unit = {
    val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment

    val ds: DataStream[String] = env.socketTextStream("master", 8888)

    //scala
    val ds1: DataStream[String] = ds.filter(_.equals("java"))


    //java
    val ds2: DataStream[String] = ds.filter(new FilterFunction[String] {
      override def filter(value: String): Boolean = {
        value.equals("java")
      }
    })

    ds2.print()


    env.execute()

  }

}
